package com.ww.grtsmanager.controller;

import com.ww.grtsmanager.bean.Video;
import com.ww.grtsmanager.vo.VideoResult;
import com.ww.grtsmanager.service.VideoService;
import com.ww.grtsmanager.vo.EduResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@CrossOrigin
@RequestMapping("/video")
public class VideoController {
    @Autowired
    private VideoService videoService;
    @RequestMapping("/deleteVideo/{id}")
    public EduResult deleteVideo(@PathVariable Integer id){
        videoService.deleteVideo(id);
        return EduResult.ok();
    }
    @RequestMapping("/videoUpload")
    public EduResult videoUpload(MultipartFile file){
        Video video = videoService.videoUpload(file);
        return EduResult.ok(video);
    }
    @RequestMapping("/getVideo/{id}")
    public EduResult getVideo(@PathVariable Integer id){
        VideoResult result=videoService.getVideo(id);
        return EduResult.ok(result);
    }
    @RequestMapping("/addVideo")
    public EduResult addVideo(@RequestBody Video video){
        videoService.addVideo(video);
        return EduResult.ok();
    }
}
